﻿using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Ewk.Extensions.UnitTests.UriExtensionsTests
{
    [TestClass]
    public class ComposeQueryStringTests
    {
        [TestMethod]
        public void ComposeQueryString_transforms_items_in_a_Dictionary_to_queryString_parameters()
        {
            const string expectedResult = "key1=value1&key2=value2&key3=value3";
            IDictionary<string, string> parameters = new Dictionary<string, string>
                {
                    {"key1", "value1"},
                    {"key2", "value2"},
                    {"key3", "value3"},
                };

            var result = parameters.ComposeQueryString();

            Assert.AreEqual(expectedResult, result);
        }

        [TestMethod]
        public void ComposeQueryString_transforms_items_in_an_empty_Dictionary_to_an_empty_string()
        {
            const string expectedResult = "key1=value1&key2=value2&key3=value3";
            IDictionary<string, string> parameters = new Dictionary<string, string>
                {
                    {"key1", "value1"},
                    {"key2", "value2"},
                    {"key3", "value3"},
                };

            var result = parameters.ComposeQueryString();

            Assert.AreEqual(expectedResult, result);
        }
    }
}